package com.lancoo.znbkxx.teacher.model.repository

import com.lancoo.cpbase.authentication.base.CurrentUser
import com.lancoo.znbkxx.teacher.Ext
import com.lancoo.znbkxx.teacher.base.BaseResponse
import com.lancoo.znbkxx.teacher.model.api.BaseRepository
import com.lancoo.znbkxx.teacher.model.api.ZnbkRetrofitClient
import com.lancoo.znbkxx.teacher.model.data.ZnbkResponse
import com.lancoo.znbkxx.teacher.service.CheckScoreService
import paperToChaKanChengJi.data.CheckScoreInfo
import paperToChaKanChengJi.data.PaperAnalysisInfo

/**
 * Created by Dadong on 2020/3/24
 * Describe:
 */
class CheckScoreRepository : BaseRepository() {
    suspend fun getPaperDetail(
            token: String,
            schoolID: String,
            courseClassID: String,
            globalGrade: String,
            paperID: String,
            layer: Int,
            userId: String,
            key: String
    ): ZnbkResponse<CheckScoreInfo> {
        val service = ZnbkRetrofitClient.getService(CheckScoreService::class.java, Ext.BASE_URL)
        return request {
            service.getPaperDetail(
                    token,
                    schoolID,
                    courseClassID,
                    globalGrade,
                    paperID,
                    layer,
                    userId,
                    key
            )
        }
    }

    suspend fun getPaperAnalysis(userID: String,
                                 token: String,
                                 setID:String,
                                 paperID: String,
                                 schoolID: String,
                                 courseClassID: String): ZnbkResponse<PaperAnalysisInfo> {
        val service = ZnbkRetrofitClient.getService(CheckScoreService::class.java, Ext.BASE_URL)
        return request {
            service.getPaperAnalysis(
                    userID,
                    token,
                    setID,
                    paperID,
                    schoolID,
                    courseClassID
            )
        }
    }


    suspend fun getExportCommentPath(templetID: String,
                                     setName: String,
                                     paperName: String,
                                     schoolId: String,
                                     tid: String,
                                     courseClassId: String,
                                     globalGrade: String,
                                     paperId: String,
                                     setId: String,
                                     subjectId: String,
                                     layer: Int,
                                     answerAnalysis: Int,
                                     zsd: Int,
                                     listenVideo: Int,
                                     listenText: Int): BaseResponse<String> {
        val service = ZnbkRetrofitClient.getService(CheckScoreService::class.java, Ext.BASE_URL)
        return request {
            service.getExportCommentPath(templetID,
                    setName,
                    paperName,
                    schoolId,
                    tid,
                    courseClassId,
                    globalGrade,
                    paperId,
                    setId,
                    subjectId,
                    layer,
                    answerAnalysis,
                    zsd,
                    listenVideo,
                    listenText)
        }
    }

    suspend fun getExportPaperScorePath(token: String,
                                        schoolId: String,
                                        paperId: String,
                                        courseClassId: String,
                                        globalGrade: String,
                                        layer: Int,
                                        courseClassName: String,
                                        key: String,
                                        userId: String): BaseResponse<String> {
        val service = ZnbkRetrofitClient.getService(CheckScoreService::class.java, Ext.BASE_URL)
        return request {
            service.getExportPaperScorePath(
                    token,
                    schoolId,
                    paperId,
                    courseClassId,
                    globalGrade,
                    layer,
                    courseClassName,
                    key,
                    userId)
        }
    }

    suspend fun openClassRzzd(
    ): ZnbkResponse<Boolean> {
        val service = ZnbkRetrofitClient.getService(CheckScoreService::class.java, Ext.RZZD_URL)
        return request {
            service.openClassRZZD(
                    CurrentUser.getSchoolID(), Ext.COURSE_CLASSID
            )
        }
    }
}